package com.lowca.news.web.jsonbean;

import java.util.Date;
import java.util.List;

import org.apache.commons.beanutils.PropertyUtils;

import com.lowca.news.entity.Article;
import com.lowca.news.util.Collections3;
import com.lowca.news.util.Exceptions;

public class ArticleWarpperBean {

	private String subject;
	private Integer clickCount;
	private Integer commentCount;
	private Integer upCount;
	private Integer downCount;
	private Date lastUpdateTime;
	private Date publishTime;
	private String author;
	private String source;
	private Boolean parseSummary = Boolean.FALSE;// 是否解析概要中的HTML代码，若解析，则不对summary进行截断处理
	private Boolean published = Boolean.TRUE;// 是否发表
	private Boolean containImage = Boolean.FALSE;
	private Boolean deleted = Boolean.FALSE;
	private Integer pageCount;// 文章内容的分页页数
	private String categoryName;
	private String tags;

	public ArticleWarpperBean(Article article) {
		try {
			PropertyUtils.copyProperties(this, article);
		} catch (Exception e) {
			Exceptions.unchecked(e);
		}
		@SuppressWarnings("unchecked")
		List<String> list = Collections3.extractToList(
				article.getArticleTags(), "name");
		this.tags = Collections3.convertToString(list, ",");
		this.categoryName = article.getCategory().getName();
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Integer getClickCount() {
		return clickCount;
	}

	public void setClickCount(Integer clickCount) {
		this.clickCount = clickCount;
	}

	public Integer getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(Integer commentCount) {
		this.commentCount = commentCount;
	}

	public Integer getUpCount() {
		return upCount;
	}

	public void setUpCount(Integer upCount) {
		this.upCount = upCount;
	}

	public Integer getDownCount() {
		return downCount;
	}

	public void setDownCount(Integer downCount) {
		this.downCount = downCount;
	}

	public Date getLastUpdateTime() {
		return lastUpdateTime;
	}

	public void setLastUpdateTime(Date lastUpdateTime) {
		this.lastUpdateTime = lastUpdateTime;
	}

	public Date getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public Boolean getParseSummary() {
		return parseSummary;
	}

	public void setParseSummary(Boolean parseSummary) {
		this.parseSummary = parseSummary;
	}

	public Boolean getPublished() {
		return published;
	}

	public void setPublished(Boolean published) {
		this.published = published;
	}

	public Boolean getContainImage() {
		return containImage;
	}

	public void setContainImage(Boolean containImage) {
		this.containImage = containImage;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	public Integer getPageCount() {
		return pageCount;
	}

	public void setPageCount(Integer pageCount) {
		this.pageCount = pageCount;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

}
